package final2107.day02;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("tom");
        list.add("tony");
        list.add("tom");
        list.add("jack");
        list.add("jack");

        List<String> tmp = new ArrayList<>();

        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String ele = it.next();
            if (!tmp.contains(ele))
                tmp.add(ele);
            else{
                it.remove();
            }
        }
        list.forEach(e-> System.out.println(e));

    }
}
